package practice.模拟右键运行;

import java.lang.reflect.Constructor;
import java.lang.reflect.Method;

public class MyAnnoTest {
    public static void main(String[] args) throws Exception{
        Class clazz = Class.forName("practice.模拟右键运行.Person");

        Constructor constructor = clazz.getDeclaredConstructor();
        constructor.setAccessible(true);
        Person person = (Person) constructor.newInstance();

        Method method = clazz.getDeclaredMethod("eat");
        if (method.isAnnotationPresent(Anno.class)) {
            method.setAccessible(true);
            method.invoke(person);
        }

        Method method1 = clazz.getDeclaredMethod("drink");
        if (method1.isAnnotationPresent(Anno.class)) {
            method1.setAccessible(true);
            method1.invoke(person);
        }

        Method method2 = clazz.getDeclaredMethod("play");
        if (method2.isAnnotationPresent(Anno.class)) {
            method2.setAccessible(true);
            method2.invoke(person);
        }

        Method method3 = clazz.getDeclaredMethod("smoke");
        if (method3.isAnnotationPresent(Anno.class)) {
            method3.setAccessible(true);
            method3.invoke(person);
        }


    }
}
